/*! 应用根路径，静态插件库路径，动态插件库路径 */
window.baseRoot = window.baseRoot || (function (src) {
    src = document.currentScript
        ? document.currentScript.src
        : document.scripts[document.scripts.length - 1].src;
    return src.substring(0, src.lastIndexOf("/") + 1)+'../../component/';
})();
window.$ = window.jQuery =  window.$ ||  layui.$

// 批量加载脚本
function getScripts(scripts, callback) {
    var progress = 0;
    $.ajaxSetup({cache:true});
    scripts.forEach(function(script) {
        progress++;
        $.getScript(script, function () {
            if (progress >= scripts.length-1){
                $("head").append(`<link rel="stylesheet" type='text/css' href='${baseRoot}plugs/notify/light.css'>`)
                callback && callback();
            }
        });
    });
}
$(function () {
    window.$body = $('body');

    /*! 注册单次事件 */
    function onEvent(event, select, callable) {
        return $body.off(event, select).on(event, select, callable);
    }

    /*! 消息组件实例 */
    $.msg = new function () {
        this.idx = [], this.mdx = [], this.shade = [0.02, '#000000'];
        /*! 关闭最新窗口 */
        this.closeLastModal = function () {
            while ($.msg.mdx.length > 0 && (this.tdx = $.msg.mdx.pop()) > 0) {
                if ($('#layui-layer' + this.tdx).size()) return layer.close(this.tdx);
            }
        };
        /*! 关闭消息框 */
        this.close = function (idx) {
            if (idx !== null) return layer.close(idx);
            for (var i in this.idx) $.msg.close(this.idx[i]);
            this.idx = [];
        };
        /*! 弹出警告框 */
        this.alert = function (msg, call) {
            var idx = layer.alert(msg, {end: call, scrollbar: false});
            return $.msg.idx.push(idx), idx;
        };
        /*! 显示成功类型的消息 */
        this.success = function (msg, time, call) {
            var idx = layer.msg(msg, {icon: 1, shade: this.shade, scrollbar: false, end: call, time: (time || 2) * 1000, shadeClose: true});
            return $.msg.idx.push(idx), idx;
        };
        /*! 显示失败类型的消息 */
        this.error = function (msg, time, call) {
            var idx = layer.msg(msg, {icon: 2, shade: this.shade, scrollbar: false, time: (time || 3) * 1000, end: call, shadeClose: true});
            return $.msg.idx.push(idx), idx;
        };
        /*! 状态消息提示 */
        this.tips = function (msg, time, call) {
            var idx = layer.msg(msg, {time: (time || 3) * 1000, shade: this.shade, end: call, shadeClose: true});
            return $.msg.idx.push(idx), idx;
        };
        /*! 显示加载提示 */
        this.loading = function (msg, call) {
            var idx = msg ? layer.msg(msg, {icon: 16, scrollbar: false, shade: this.shade, time: 0, end: call}) : layer.load(2, {time: 0, scrollbar: false, shade: this.shade, end: call});
            return $.msg.idx.push(idx), idx;
        };
        /*! 页面加载层 */
        this.page = new function () {
            this.$body = $('body>.think-page-loader');
            this.$main = $('.think-page-body+.think-page-loader');
            this.stat = function () {
                return this.$body.is(':visible');
            }, this.done = function () {
                $.msg.page.$body.fadeOut();
            }, this.show = function () {
                this.stat() || this.$main.removeClass('layui-hide').show();
            }, this.hide = function () {
                if (this.time) clearTimeout(this.time);
                this.time = setTimeout(function () {
                    ($.msg.page.time = 0) || $.msg.page.$main.fadeOut();
                }, 200);
            };
        };
        /*! 确认对话框 */
        this.confirm = function (msg, ok, no) {
            return layer.confirm(msg, {title: '操作确认', btn: ['确认', '取消']}, function (idx) {
                (typeof ok === 'function' && ok.call(this, idx)), $.msg.close(idx);
            }, function (idx) {
                (typeof no === 'function' && no.call(this, idx)), $.msg.close(idx);
            });
        };
        /*! 自动处理JSON数据 */
        this.auto = function (ret, time) {
            var url = ret.url || (typeof ret.data === 'string' ? ret.data : '');
            var msg = ret.msg || (typeof ret.info === 'string' ? ret.info : '');
            if (parseInt(ret.code) === 1 && time === 'false') {
                return url ? location.href = url : $.form.reload();
            } else return (parseInt(ret.code) === 1) ? this.success(msg, time, function () {
                $.msg.closeLastModal(url ? location.href = url : $.form.reload());
            }) : this.error(msg, 3, function () {
                url ? location.href = url : '';
            });
        };
    };

    getScripts([
        baseRoot+'plugs/jquery/md5.min.js',
        baseRoot+'plugs/upload/upload.js',
        baseRoot+'plugs/notify/notify.min.js',
        baseRoot+'plugs/jquery/compressor.min.js',
       ,
    ],function(){

        function Adapter(option, uploader) {
            this.uploader = uploader
            this.config = function (option) {
                return (this.option = Object.assign({}, this.option || {}, option || {})), this;
            }
            this.init = function (option) {
                this.uploader && this.uploader.config.elem.next().val('');
                this.files = {}, this.loader = 0, this.count = {total: 0, error: 0, success: 0};
                return this.config(option).config({safe: this.option.safe || 0, type: this.option.type || ''});
            }
            this.init(option);
        }

        // 文件推送
        Adapter.prototype.upload = function (files, done) {
            var that = this.init();
            layui.each(files, function (index, file) {
                that.count.total++, file.index = index, that.files[index] = file;
                if (that.option.size && file.size > that.option.size) {
                    that.event('upload.error', {file: file}, file, '大小超限');
                } else if (!that.option.hide) {
                    file.notify = new NotifyExtend(file);
                }
            }), layui.each(files, function (index, file) {
                // 禁传异常状态文件
                if (typeof file.xstate === 'number' && file.xstate === -1) return;
                // 图片限宽限高压缩
                console.log(file.size,file,/^image\//.test(file.type) , (file.maxWidth + file.maxHeight + file.cutWidth + file.cutHeight > 0 || file.quality !== 1),'--file')
                if (/^image\//.test(file.type) && (file.maxWidth + file.maxHeight + file.cutWidth + file.cutHeight > 0 || file.quality !== 1)) {
                    // require(['compressor'], function (Compressor) {
                        new Compressor(file, {
                            quality: file.quality, //resize: 'cover',
                            //width: file.cutWidth || 0, height: file.cutHeight || 0,
                            maxWidth: file.maxWidth, maxHeight: file.maxHeight,
                            success(blob) {
                                console.log(blob,'---blob')
                                blob.index = file.index, blob.notify = file.notify, blob.path = file.path, files[index] = blob;
                                that.hash(files[index]).then(function (file) {
                                    console.log('被压缩',file.size)
                                    if(file.size< 2* 1024 *1024){
                                        that.event('upload.hash', file).request(file, done);
                                    }else{
                                        that.event('upload.hash', file).requestBig(file, done);
                                    }
                                });
                            }, error: function () {
                                that.event('upload.error', {file: file}, file, '压缩失败');
                            }
                        });
                    // });
                } else {
                    that.hash(file).then(function (file) {
                        if(file.size< 2* 1024 *1024){
                            that.event('upload.hash', file).request(file, done);
                        }else{
                            that.event('upload.hash', file).requestBig(file, done);
                        }
                    });
                }
            });
        };

        // 文件上传
        Adapter.prototype.request = function (file, done) {
            // key: file.xkey,
            var that = this, data = { safe: that.option.safe, uptype: that.option.type};
            data.file_size = file.size, data.name = file.name, data.hash = file.xmd5, data.mime_type = file.type, data.ext = file.xext;
            jQuery.ajax("/admin/utils/upload/state", {
                data: data, method: 'post', success: function (ret) {
                    file.id = ret.data.id || 0, file.xurl = ret.data.url,file.full_url = ret.data.full_url;
                    file.xsafe = ret.data.safe, file.xpath = ret.data.key, file.xtype = ret.data.uptype;
                    if (parseInt(ret.code) === 404) {
                        var uploader = {};
                        uploader.url = ret.data.server || '/admin/utils/upload/file';
                        uploader.form = new FormData();
                        uploader.form.append('hash', file.xmd5);
                        if (ret.data.uptype === 'qiniu') {
                            uploader.form.append('token', ret.data.token);
                        } else if (ret.data.uptype === 'alioss') {
                            uploader.form.append('policy', ret.data['policy']);
                            uploader.form.append('signature', ret.data['signature']);
                            uploader.form.append('OSSAccessKeyId', ret.data['OSSAccessKeyId']);
                            uploader.form.append('success_action_status', '200');
                            uploader.form.append('Content-Disposition', 'inline;filename=' + encodeURIComponent(file.name));
                        } else if (ret.data.uptype === 'txcos') {
                            uploader.form.append('q-ak', ret.data['q-ak']);
                            uploader.form.append('policy', ret.data['policy']);
                            uploader.form.append('q-key-time', ret.data['q-key-time']);
                            uploader.form.append('q-signature', ret.data['q-signature']);
                            uploader.form.append('q-sign-algorithm', ret.data['q-sign-algorithm']);
                            uploader.form.append('success_action_status', '200');
                            uploader.form.append('Content-Disposition', 'inline;filename=' + encodeURIComponent(file.name));
                        } else if (ret.data.uptype === 'upyun') {
                            uploader.form.delete('key');
                            uploader.form.delete('safe');
                            uploader.form.delete('uptype');
                            uploader.form.append('save-key', ret.data['key']);
                            uploader.form.append('policy', ret.data['policy']);
                            uploader.form.append('authorization', ret.data['authorization']);
                            uploader.form.append('Content-Disposition', 'inline;filename=' + encodeURIComponent(file.name));
                        }
                        uploader.form.append('file', file, file.name);
                        $.ajax({
                            url: uploader.url, data: uploader.form, type: 'post', xhr: function (xhr) {
                                xhr = new XMLHttpRequest();
                                return xhr.upload.addEventListener('progress', function (event) {
                                    file.xtotal = event.total, file.xloaded = event.loaded || 0;
                                    that.progress((file.xloaded / file.xtotal * 100).toFixed(2), file)
                                }), xhr;
                            }, contentType: false, error: function () {
                                that.event('upload.error', {file: file}, file, '接口异常');
                            }, processData: false, success: function (ret) {
                                // 兼容数据格式
                                if (typeof ret === 'string' && ret.length > 0) try {
                                    ret = JSON.parse(ret) || ret;
                                } catch (e) {
                                    console.log(e)
                                }
                                if (typeof ret !== 'object') {
                                    ret = {code: 1, url: file.xurl, info: '上传成功'};
                                }
                                /*! 检查单个文件上传返回的结果 */
                                if (typeof ret === 'object' && ret.code !=0 ) {
                                    that.event('upload.error', {file: file}, file, ret.info || '上传失败');
                                } else {
                                    that.done(ret, file.index, file, done, '上传成功');
                                }
                            }
                        });
                    } else if (parseInt(ret.code) === 0) {
                        (file.xurl = ret.data.url), that.progress('100.00', file);
                        that.done({code: 0, url: file.xurl, info: file.xstats}, file.index, file, done, '秒传成功');
                    } else {
                        that.event('upload.error', {file: file}, file, ret.info || ret.error.message || '上传出错！');
                    }
                }
            });
        };

        // 文件上传 分片上传
        Adapter.prototype.requestBig = function (file, done) {
            // key: file.xkey,
            var that = this, data = { safe: that.option.safe, uptype: that.option.type};
            data.file_size = file.size, data.name = file.name, data.hash = file.xmd5, data.mime_type = file.type, data.ext = file.xext;
            jQuery.ajax("/admin/utils/upload/state", {
                data: data, method: 'post', success: function (ret) {
                    file.id = ret.data.id || 0, file.xurl = ret.data.url,file.full_url = ret.data.full_url;
                    file.xsafe = ret.data.safe, file.xpath = ret.data.key, file.xtype = ret.data.uptype;
                    if (parseInt(ret.code) === 404) {
                        var shardSize = 2 * 1024 *1024,
                            shardCount = Math.ceil(file.size / shardSize);
                        var uploadFileBig = function(file,i){
                            if(i>=shardCount){
                                return ;
                            }
                            var start = i * shardSize;
                            var end = start + shardSize;
                            var packet = file.slice(start,end);//文件切片
                            var uploader = {};
                            uploader.url = ret.data.server || '/admin/utils/upload/fileBig';
                            uploader.form = new FormData();
                            uploader.form.append('key',file.xkey);
                            uploader.form.append('hash',file.xmd5);
                            uploader.form.append('chunk', packet);
                            uploader.form.append('name', file.name);
                            uploader.form.append('chunkAll', shardCount);
                            uploader.form.append('chunkNumber', i+1);

                            $.ajax({
                                url: uploader.url, data: uploader.form, type: 'post',
                                contentType: false,
                                processData: false,
                                error: function () {
                                    that.event('upload.error', {file: file}, file, '接口异常');
                                },success: function (ret) {
                                    // 兼容数据格式
                                    if (typeof ret === 'string' && ret.length > 0) try {
                                        ret = JSON.parse(ret) || ret;
                                    } catch (e) {
                                        console.log(e)
                                    }
                                    if(ret.code==201){
                                        i++;
                                        // 上传进度
                                        that.progress((i / shardCount * 100).toFixed(2), file)
                                        uploadFileBig(file, i)
                                    }else if(ret.code==502){
                                        /*  失败后，每2秒继续传一次分片文件  */
                                        setInterval(function () { uploadFileBig(file, i) }, 2000);
                                    }else if(ret.code == 0){
                                        // 上传成功
                                        that.done(ret, file.index, file, done, '上传成功');
                                    }else if(ret.code == 500){
                                        that.event('upload.error', {file: file}, file, ret.msg || '上传失败');
                                    }else{
                                        that.event('upload.error', {file: file}, file, ret.msg || '上传失败，未知错误');
                                    }
                                }
                            });
                        }

                        uploadFileBig(file,0);// 上次第一片
                    } else if (parseInt(ret.code) === 0) {
                        (file.xurl = ret.data.url), that.progress('100.00', file);
                        that.done({code: 0, url: file.xurl, info: file.xstats}, file.index, file, done, '秒传成功');
                    } else {
                        that.event('upload.error', {file: file}, file, ret.info || ret.error.message || '上传出错！');
                    }
                }
            });
        };

        // 上传进度
        Adapter.prototype.progress = function (number, file) {
            this.event('upload.progress', {number: number, file: file});
            if (file.notify) file.notify.setProgress(number);
        };

        // 上传结果
        Adapter.prototype.done = function (ret, idx, file, done, message) {
            file.xurl = file.xurl || ret.data.full_url
            /*! 检查单个文件上传返回的结果 */
            if (ret.code != 0) return $.msg.tips(ret.msg || '文件上传失败！');
            if (typeof file.xurl !== 'string') return $.msg.tips('无效的文件上传对象！');
            if(message!='秒传成功'){
                var data = {id: file.id,
                    url:ret.data.url, hash: file.xmd5,
                    image_width:ret.data.image_width || 0,
                    image_height:ret.data.image_height || 0,
                };
                jQuery.post("/admin/utils/upload/done", data);
            }

            /*! 单个文件上传成功结果处理 */
            if (typeof done === 'function') {
                done.call(this.option.elem, file, this.files['id']);
            } else if (this.option.mult < 1 && this.option.elem.data('input')) {
                $(this.option.elem.data('input')).val(file.full_url).trigger('change', file);
                $(this.option.elem.data('input')).siblings('img').attr("src", file.full_url);
            }
            // 文件上传成功事件
            this.event('push', file.xurl).event('upload.done', {file: file, data: ret}, file, message);
            /*! 所有文件上传完成后结果处理 */
            if (this.count.success + this.count.error >= this.count.total) {
                this.option.hide || $.msg.close(this.loader);
                if (this.option.mult > 0 && this.option.elem.data('input')) {
                    var urls = this.option.elem.data('input').value || [];
                    console.log(urls,'--urls')
                    if (typeof urls === 'string') urls = urls.split('|');
                    for (var i in this.files) urls.push(this.files[i].full_url);
                    $(this.option.elem.data('input')).val(urls.join(',')).trigger('change', this.files);
                }
                this.event('upload.complete', {file: this.files}, file).init().uploader && this.uploader.reload();
            }
        };

        /*! 触发事件过程 */
        Adapter.prototype.event = function (name, data, file, message) {
            if (name === 'upload.error') {
                this.count.error++, file.xstate = -1, file.xstats = message;
                if (file.notify) file.notify.setError(message || file.xstats || '');
            } else if (name === 'upload.done') {
                this.count.success++, file.xstate = 1, file.xstats = message;
                if (file.notify) file.notify.setSuccess(message || file.xstats || '')
            }
            if (this.option.elem) {
                this.option.elem.triggerHandler(name, data);
            }
            return this;
        };

        /**
         * 计算文件 HASH 值
         * @param {File} file 文件对象
         * @return {Promise}
         */
        Adapter.prototype.hash = function (file) {
            var defer = jQuery.Deferred();
            file.xext = file.name.indexOf('.') > -1 ? file.name.split('.').pop() : 'tmp';

            /*! 兼容不能计算文件 HASH 的情况 */
            // var IsDate = '{$nameType|default=""}'.indexOf('date') > -1;
            var IsDate = false;// 默认hash
            if (!window.FileReader || IsDate) return jQuery.when((function (xmd5, chars) {
                while (xmd5.length < 32) xmd5 += chars.charAt(Math.floor(Math.random() * chars.length));
                return SetFileXdata(file, xmd5, 6), defer.promise();
            })(layui.util.toDateString(Date.now(), 'yyyyMMddHHmmss-'), '0123456789'));

            /*! 读取文件并计算 HASH 值 */
            return new LoadNextChunk(file).ReadAsChunk();

            function SetFileXdata(file, xmd5, slice) {
                file.xmd5 = xmd5, file.xstate = 0, file.xstats = '';
                file.xkey = file.xmd5.substring(0, slice || 2) + '/' + file.xmd5.substring(slice || 2) + '.' + file.xext;
                if (file.path) file.xkey = file.path + '/' + file.xkey;
                return defer.resolve(file, file.xmd5, file.xkey), file;
            }

            function LoadNextChunk(file) {
                var that = this, reader = new FileReader(), spark = new SparkMD5.ArrayBuffer();
                var slice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice;
                this.chunkIdx = 0, this.chunkSize = 2097152, this.chunkTotal = Math.ceil(file.size / this.chunkSize);
                reader.onload = function (event) {
                    spark.append(event.target.result);
                    ++that.chunkIdx < that.chunkTotal ? that.ReadAsChunk() : SetFileXdata(file, spark.end());
                    if (file.notify) file.notify.setProgress((that.chunkIdx/that.chunkTotal*100).toFixed(2));
                }, reader.onerror = function () {
                    defer.reject();
                }, this.ReadAsChunk = function () {
                    this.start = that.chunkIdx * that.chunkSize;
                    this.loaded = this.start + that.chunkSize >= file.size ? file.size : this.start + that.chunkSize;
                    reader.readAsArrayBuffer(slice.call(file, this.start, this.loaded));
                    defer.notify(file, (this.loaded / file.size * 100).toFixed(2));
                    return defer.promise();
                };
            }
        };

        var allowMime = {};

        function UploadAdapter(elem, done) {
            return new (function (elem, done, that) {

                /*! 初始化变量 */
                that = this;
                this.option = {elem: $(elem), exts: [], mimes: []};
                this.option.size = this.option.elem.data('size') || 0;
                this.option.file = this.option.elem.data('file') || 'file';// 默认是传文件
                this.option.safe = this.option.elem.data('safe') ? 1 : 0;
                this.option.hide = this.option.elem.data('hload') ? 1 : 0;
                this.option.mult = this.option.elem.data('multiple') > 0;
                this.option.path = (this.option.elem.data('path') || '').replace(/\W/g, '');
                this.option.type = this.option.safe ? 'local' : this.option.elem.attr('data-uptype') || '';
                this.option.quality = parseFloat(this.option.elem.data('quality') || '1.0');
                this.option.maxWidth = parseInt(this.option.elem.data('max-width') || '0');
                this.option.maxHeight = parseInt(this.option.elem.data('max-height') || '0');
                this.option.cutWidth = parseInt(this.option.elem.data('cut-width') || '0');
                this.option.cutHeight = parseInt(this.option.elem.data('cut-height') || '0');
                /*! 查找表单元素, 如果没有找到将不会自动写值 */
                if (!this.option.elem.data('input') && this.option.elem.data('field')) {
                    this.$input = $('input[name="' + this.option.elem.data('field') + '"]:not([type=file])');
                    this.option.elem.data('input', this.$input.size() > 0 ? this.$input.get(0) : null);

                }

                /*! 文件选择筛选，使用 MIME 规则过滤文件列表 */
                $((this.option.elem.data('type') || '').split(',')).map(function (i, e) {
                    if (allowMime[e]) that.option.exts.push(e), that.option.mimes.push(allowMime[e]);
                });

                /*! 初始化上传组件 */
                this.adapter = new Adapter(this.option, layui.upload.render({
                    url: '/admin/utils/upload/file',
                    auto: false, elem: elem,
                    accept: 'file',
                    multiple: this.option.mult,
                    exts: this.option.exts.join('|'),
                    acceptMime: this.option.mimes.join(','),
                    choose: function (obj) {
                        obj.items = [], obj.files = obj.pushFile();
                        layui.each(obj.files, function (idx, file) {
                            obj.items.push(file);
                            file.path = that.option.path;
                            file.quality = that.option.quality;
                            file.maxWidth = that.option.maxWidth;
                            file.maxHeight = that.option.maxHeight;
                            file.cutWidth = that.option.cutWidth;
                            file.cutHeight = that.option.cutHeight;
                        });
                        that.adapter.event('upload.choose', obj.items);
                        that.adapter.upload(obj.items, done);
                        layui.each(obj.files, function (idx) {
                            delete obj.files[idx];
                        });
                    }
                }));
            })(elem, done)
        }

        UploadAdapter.adapter  = Adapter;


        // 全局文件上传
        $.fn.uploadFile = function(callable,initialize){
            return this.each(function (idx, elem) {
                if (elem.dataset.inited) return false; else elem.dataset.inited = 'true';
                elem.dataset.multiple = '|images|files|'.indexOf(elem.dataset.file || 'default') > -1 ? '1' : '0';
                UploadAdapter(elem, callable), setTimeout(function () {
                    typeof initialize === 'function' && initialize.call(elem, elem);
                }, 100);
            });
        }


        /*! 注册 data-file 事件行为 */
        onEvent('click', '[data-file]', function () {
            this.id = this.dataset.id = this.id || (function (date) {
                return (date + Math.random()).replace('0.', '');
            })(layui.util.toDateString(Date.now(), 'yyyyMMddHHmmss-'));

            // data-file 取值
            // image 单图上传  images 多图上传
            // file 单文件 files 多文件
            // select 选择图片上传 selects 选择多图上传

            // 上传图片，弹出图片选择框进行选择上传
            if (typeof this.dataset.file === 'string' && '|select|selects'.indexOf(this.dataset.file || 'default')>-1) {
                let input = layui.$('input[name="'+this.dataset.field+'"]');
               return parent.layer.open({
                    type: 2,
                    title: "选择图片",
                    content: "/app/admin/upload/attachment?ext=jpg,jpeg,png,gif,bmp",
                    area: ["95%", "90%"],
                    success: function (layero, index) {
                        parent.layui.$("#layui-layer" + index).data("callback", function (data) {
                            console.log(data.url,input,'---选择')
                            input.val(data.url).prev().attr("src", data.url);
                        });
                    }
                });
            }
            // 其他文件上传
            if (!this.dataset.inited) $(this).uploadFile(undefined, function () {
                $(this).trigger('upload.start');
            });
        });


        /**
         * 上传状态提示扩展插件
         * @param {File} file 文件对象
         * @constructor
         */
        function NotifyExtend(file) {
            var that = this;
            this.notify = GrowlNotification.notify({width: 260, title: file.name, showProgress: true, description: '上传进度 <span data-upload-progress>0%</span>', type: 'default', position: 'top-right', closeTimeout: 0});
            this.$elem = $(this.notify.notification.nodes);
            this.$elem.find('.growl-notification__progress').addClass('is-visible');
            this.$elem.find('.growl-notification__progress-bar').addClass('transition');
            this.setProgress = function (number) {
                this.$elem.find('[data-upload-progress]').html(number + '%');
                this.$elem.find('.growl-notification__progress-bar').css({width: number + '%'});
                return this;
            }, this.setError = function (message) {
                this.$elem.find('.growl-notification__desc').html(message || '文件上传失败！');
                this.$elem.removeClass('growl-notification--default').addClass('growl-notification--error')
                return this.close();
            }, this.setSuccess = function (message) {
                this.setProgress('100.00');
                this.$elem.find('.growl-notification__desc').html(message || '文件上传成功！');
                this.$elem.removeClass('growl-notification--default').addClass('growl-notification--success');
                return this.close();
            }, this.close = function (timeout) {
                return setTimeout(function () {
                    that.notify.close();
                }, timeout || 2000), this;
            };
        }

    })
    
})